package com.itheima.service.impl;

import com.itheima.dao.MemberDao;
import com.itheima.dao.OrderDao;
import com.itheima.service.ReportService;
import com.itheima.utils.DateUtils;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service
public class ReportServiceImpl implements ReportService {


    @Autowired
    private MemberDao memberDao;
    @Autowired
    private OrderDao orderDao;
//查询运用数据

/**
 reportDate:null,
 todayNewMember :0,
 totalMember :0,
 thisWeekNewMember :0,
 thisMonthNewMember :0,
 todayOrderNumber :0,
 todayVisitsNumber :0,
 thisWeekOrderNumber :0,
 thisWeekVisitsNumber :0,
 thisMonthOrderNumber :0,
 thisMonthVisitsNumber :0,
 hotSetmeal :[
 {name:'阳光爸妈升级肿瘤12项筛查（男女单人）体检套餐',setmeal_count:200,proportion:0.222},
 {name:'阳光爸妈升级肿瘤12项筛查体检套餐',setmeal_count:200,proportion:0.222}
 ]
 */
    public Map<String,Object> getBusinessReportData(){
        //今日新增会员数
        Long todayNewMember = memberDao.findMemberCountForToday();
        //总会员数据
        Long totalMember = memberDao.findMemberTotalCount();
        //本周新增会员数
        Long thisWeekNewMember = memberDao.findMemberCountForWeek();
        //本月新增会员数
        Long thisMonthNewMember = memberDao.findMemberCountForMonth();

        //今日预约数
        Long todayOrderNumber = orderDao.findOrderCountForToday();
        //今日到诊数
        Long todayVisitsNumber = orderDao.findVisitsCountForToday();
        //本周预约数
        Long thisWeekOrderNumber = orderDao.findMemberCountForWeek();
        //本周到诊数
        Long thisWeekVisitsNumber = orderDao.findVisitsCountForWeek();
        //本月预约数
        Long thisMonthOrderNumber = orderDao.findMemberCountForMonth();
        //本月到诊数
        Long thisMonthVisitsNumber = orderDao.findVisitsCountForMonth();

        //热门套餐
        List<Map> hotSetmeal = orderDao.findHotSetmeal();

        Map<String,Object> result = new HashMap<>();
        try {
            result.put("reportDate",DateUtils.parseDate2String(DateUtils.getToday()));
        } catch (Exception e) {
            e.printStackTrace();
        }
        result.put("todayNewMember",todayNewMember);
        result.put("totalMember",totalMember);
        result.put("thisWeekNewMember",thisWeekNewMember);
        result.put("thisMonthNewMember",thisMonthNewMember);
        result.put("todayOrderNumber",todayOrderNumber);
        result.put("thisWeekOrderNumber",thisWeekOrderNumber);
        result.put("thisMonthOrderNumber",thisMonthOrderNumber);
        result.put("todayVisitsNumber",todayVisitsNumber);
        result.put("thisWeekVisitsNumber",thisWeekVisitsNumber);
        result.put("thisMonthVisitsNumber",thisMonthVisitsNumber);
        result.put("hotSetmeal",hotSetmeal);

        /*
        * 套餐名称 预约数量 占比 备注
        * */

        return result;
    }
}
